import express from 'express';
import * as carController from './car.controller';
const router = express.Router();
import { fileInterceptor, fileProcessor } from './car.middleware';
import { validateLoginData, authGuard, userGuard } from '../auth/auth.middleware';

/**
 * 获取内容
 */
router.get('/car', userGuard, carController.index);

/**
 * 获取内容(按 ID)
 */
router.get('/car/:postId', userGuard, carController.carDetail);

/**
 * 按关键字查询（模糊查询）
 */
router.get('/getCarByKey', carController.selectByKey);

/**
 * 创建内容
 */
router.post('/car', authGuard, carController.store);

/**
 * 更新内容
 */
router.patch('/car/:postId', carController.update);

/**
 * 删除内容
 */
router.post('/carDestroy', authGuard, carController.destroy);

/**
 * 修改状态
 */
router.patch('/carStatus', carController.status);

/**
 * 上传文件
 */
router.post('/carFiles', authGuard, fileInterceptor, fileProcessor, carController.uploads);

/**
 * 文件服务
 */
router.get('/carFiles/:fileId/serve', carController.serve);

/**
 * 获取文件 ID
 */
router.post('/getCarFilesId', carController.getFileName);

/**
 * 导出路由
 */
export default router;
